#!/bin/sh

file="$1"

case "$(file --mime-type -bL "$file")" in
    audio/* | video/*) mediainfo "$file" ;;
    image/*)
        chafa -f sixel -s "$2x$3" --animate off --polite on "$file"
        exit 1
        ;;
    application/pdf | application/epub+zip)
        mutool draw -o - "$file" 1 | chafa -f sixel -s "$2x$3" --polite on
        exit 1
        ;;
    application/gzip) tar -tf "$file" ;;
    application/zip) zipinfo -1 "$file" ;;
    text/* | application/json) cat "$file" ;;
    *)
        printf "%s\n" "----- File Type Classification -----"
        file -bL "$file"
        ;;
esac
